use std::sync::LazyLock;
use std::time::Duration;
use tower_http::timeout::TimeoutLayer;
use crate::configuration;

static TIMEOUT_LAYER: LazyLock<TimeoutLayer> = LazyLock::new(|| {
    let config = configuration::server();
    TimeoutLayer::new(Duration::from_secs(config.timeout() as u64))
});

/// 超时中间件
pub fn get_timeout_layer() -> &'static TimeoutLayer {
    &TIMEOUT_LAYER
}
